Interactive image recoloring

ABSTRACT

Disclosed are systems, methods, and computer-readable storage media to perform an interactive image recolorization process. The method includes receiving user input including a stroke drawn on an image presented on a client device. The stroke comprises a user-specified color. The method further includes determining a region of interest in the image. The method further includes recolorizing the region of interest on the image based on the user-specified color and causing presentation of a result of the recolorization on the client device.

CLAIM OF PRIORITY

This application is a continuation of and claims the benefit of priorityof U.S. patent application Ser. No. 16/659,073, filed on Oct. 21, 2019,which is a continuation of and claims the benefit of priority of U.S.patent application Ser. No. 16/204,857, filed on Nov. 29, 2018, which isa continuation of and claims the benefit of priority of U.S. patentapplication Ser. No. 15/594,083, filed on May 12, 2017, each of whichare hereby incorporated by reference herein in their entireties.

TECHNICAL FIELD

The present disclosure generally relates to the technical field ofspecial-purpose machines for performing image recoloring, includingcomputerized variants of such special-purpose machines and improvementsto such variants, and to the technologies by which such special-purposemachines become improved compared to other special-purpose machines thatperform image recoloring. In particular, the present disclosureaddresses systems and methods for allowing users to interactivelyrecolor images.

BACKGROUND

As the popularity of social networking grows, the number of digitalimages generated and shared using social networks grows as well. Priorto sharing such digital images on social networks, users may wish toaugment the image. For example, users may wish to recolor portions ofthe image. Conventional methods for digitally recoloring images, alsoreferred to as image “colorization” or “recolorization,” requireconsiderable user intervention (e.g., substantial annotation) andcomputational processing and are thus tedious, time-consuming, andcomputationally expensive tasks. Aspects of the present disclose addressenhanced image recolorization techniques that may be especiallyoptimized for deployment with mobile devices (e.g., smart phones).

BRIEF DESCRIPTION OF THE DRAWINGS

In the drawings, which are not necessarily drawn to scale, like numeralsmay describe similar components in different views. Like numerals havingdifferent letter suffixes may represent different instances of similarcomponents. Some embodiments are illustrated by way of example, and notlimitation, in the figures of the accompanying drawings.

FIG. 1 is a block diagram showing an example messaging system forexchanging data (e.g., messages and associated content) over a network,according to some embodiments.

FIG. 2 is block diagram illustrating further details regarding themessaging system, according to some embodiments.

FIG. 3 is a schematic diagram illustrating data which may be stored in adatabase of the messaging system, according to some embodiments.

FIG. 4 is a block diagram illustrating functional components of an imageprocessing system that forms part of the messaging system, according tosome example embodiments.

FIGS. 5-8 are flow charts illustrating operations of the imageprocessing system in performing an example method for digital imageediting, according to some embodiments.

FIGS. 9A, 9B, 9C, and 9D are interface diagrams illustrating aspects ofuser interfaces provided by the messaging system, according to someembodiments.

FIG. 10 is a block diagram illustrating a representative softwarearchitecture, which may be used in conjunction with various hardwarearchitectures herein described.

FIG. 11 is a block diagram illustrating components of a machine,according to some exemplary embodiments, able to read instructions froma machine-readable medium (e.g., a machine-readable storage medium) andperform any one or more of the methodologies discussed herein.

DETAILED DESCRIPTION

The description that follows includes systems, methods, techniques,instruction sequences, and computing machine program products thatembody illustrative embodiments of the disclosure. In the followingdescription, for the purposes of explanation, numerous specific detailsare set forth in order to provide an understanding of variousembodiments of the inventive subject matter. It will be evident,however, to those skilled in the art, that embodiments of the inventivesubject matter may be practiced without these specific details. Ingeneral, well-known instruction instances, protocols, structures, andtechniques are not necessarily shown in detail.

Aspects of the present disclosure include systems, methods, techniques,instruction sequences, and computing machine program products that allowa user to interactively recolor image regions. As an example, a user mayuse a mobile device to capture an image. Using aspects of the presentdisclosure, the user may draw a single scribble on or around a region ofthe image such as an object depicted in the image. The user may furtherspecify one or more desired colors for the region. The systemautomatically swaps the original color of the region with the desiredcolor(s) in a process referred to as “recolorization.”

Consistent with some embodiments, in swapping the original color of theregion, the system employs an algorithmic form of graphical modelinference that takes as input an image, a mask based on the userscribble, and the user specified color. Specifically, the user scribbledefines certain pixels in the input image with the desired color. Pixelsinside the scribble mask (expect for the pixels of the scribble itself)are treated as unknowns, and the system uses graphical model inferenceto solve for them, with a constraint that neighboring pixels that havesimilar luminance should also be similar in color as well. Pixelsoutside of the scribble mask remain unchanged.

To optimize the speed of the recoloring, images are preprocessed to finetune the single user scribble to precisely identify a boundary of aregion of interest, which is used as the mask input to the graphicalmodel inference-based recolorization process. To further automate theabove process as well as minimize the user interface flow, the systemmay simulate additional user strokes with color.

Additionally, in some embodiments, the system performs recolorization ona downsized region of interest to optimize memory and othercomputational resource usage during recolorization, and the system thenscales the recolorization result back to original resolution. In someinstances, this process may introduce blur into the recolorizationresult. To solve the blurring problem, the system may combine aluminance channel of the original resolution region of interest with acolor channel of the scaled region of interest to generate the finalrecolorization result.

FIG. 1 is a block diagram showing an example messaging system 100 forexchanging data (e.g., messages and associated content) over a network.The messaging system 100 includes multiple client devices 102, each ofwhich hosts a number of applications including a messaging clientapplication 104. Each messaging client application 104 iscommunicatively coupled to other instances of the messaging clientapplication 104 and a messaging server system 108 via a network 106(e.g., the Internet). As used herein, the term “client device” may referto any machine that interfaces with a communications network (such asthe network 106) to obtain resources from one or more server systems orother client devices. A client device may be, but is not limited to, amobile phone, desktop computer, laptop, portable digital assistant(PDA), smart phone, tablet, ultra book, netbook, laptop, multi-processorsystem, microprocessor-based or programmable consumer electronicssystem, game console, set-top box, or any other communication devicethat a user may use to access a network.

In the example shown in FIG. 1, each messaging client application 104 isable to communicate and exchange data with another messaging clientapplication 104 and with the messaging server system 108 via the network106. The data exchanged between the messaging client applications 104,and between a messaging client application 104 and the messaging serversystem 108, includes functions (e.g., commands to invoke functions) aswell as payload data (e.g., text, audio, video, or other multimediadata).

The network 106 may include, or operate in conjunction with, an ad hocnetwork, an intranet, an extranet, a virtual private network (VPN), alocal area network (LAN), a wireless LAN (WLAN), a wide area network(WAN), a wireless WAN (WWAN), a metropolitan area network (MAN), theInternet, a portion of the Internet, a portion of the Public SwitchedTelephone Network (PSTN), a plain old telephone service (POTS) network,a cellular telephone network, a wireless network, a Wi-Fi® network,another type of network, or a combination of two or more such networks.For example, the network 106 or a portion of the network 106 may includea wireless or cellular network and the connection to the network 106 maybe a Code Division Multiple Access (CDMA) connection, a Global Systemfor Mobile communications (GSM) connection, or another type of cellularor wireless coupling. In this example, the coupling may implement any ofa variety of types of data transfer technology, such as Single CarrierRadio Transmission Technology (1×RTT), Evolution-Data Optimized (EVDO)technology, General Packet Radio Service (GPRS) technology, EnhancedData rates for GSM Evolution (EDGE) technology, third-GenerationPartnership Project (3GPP) including 3G, fourth-generation wireless (4G)networks, Universal Mobile Telecommunications System (UMTS), High-SpeedPacket Access (HSPA), Worldwide Interoperability for Microwave Access(WiMAX), Long-Term Evolution (LTE) standard, or others defined byvarious standard-setting organizations, other long-range protocols, orother data transfer technology.

The messaging server system 108 provides server-side functionality viathe network 106 to a particular messaging client application 104. Whilecertain functions of the messaging system 100 are described herein asbeing performed by either a messaging client application 104 or by themessaging server system 108, it will be appreciated that the location ofcertain functionality either within the messaging client application 104or the messaging server system 108 is a design choice. For example, itmay be technically preferable to initially deploy certain technology andfunctionality within the messaging server system 108, but to latermigrate this technology and functionality to the messaging clientapplication 104 where a client device 102 has a sufficient processingcapacity.

The messaging server system 108 supports various services and operationsthat are provided to the messaging client application 104. Suchoperations include transmitting data to, receiving data from, andprocessing data generated by the messaging client application 104. Thisdata may include message content, client device information, geolocationinformation, media annotation and overlays, message content persistenceconditions, social network information, and live event information, asexamples. Data exchanges within the messaging system 100 are invoked andcontrolled through functions available via user interfaces (UIs) of themessaging client application 104.

Turning now specifically to the messaging server system 108, anApplication Programming Interface (API) server 110 is coupled to, andprovides a programmatic interface to, an application server 112. Theapplication server 112 is communicatively coupled to a database server118, which facilitates access to a database 120 in which is stored dataassociated with messages processed by the application server 112.

The API server 110 receives and transmits message data (e.g., commandsand message payloads) between the client device 102 and the applicationserver 112. Specifically, the API server 110 provides a set ofinterfaces (e.g., routines and protocols) that can be called or queriedby the messaging client application 104 in order to invoke functionalityof the application server 112. The API server 110 exposes variousfunctions supported by the application server 112, including accountregistration; login functionality; the sending of messages, via theapplication server 112, from a particular messaging client application104 to another messaging client application 104; the sending of mediafiles (e.g., images or video) from a messaging client application 104 tothe application server 112, for possible access by another messagingclient application 104; the setting of a collection of media data (e.g.,story); the retrieval of a list of friends of a user of a client device102; the retrieval of such collections; the retrieval of messages andcontent; the adding and deletion of friends to and from a social graph;the location of friends within a social graph; and the detecting of anapplication event (e.g., relating to the messaging client application104).

The application server 112 hosts a number of applications andsubsystems, including a messaging server application 114 and a socialnetwork system 116. The messaging server application 114 implements anumber of message processing technologies and functions, particularlyrelated to the aggregation and other processing of content (e.g.,textual and multimedia content) included in messages received frommultiple instances of the messaging client application 104. As will bedescribed in further detail, the text and media content from multiplesources may be aggregated into collections of content (e.g., calledstories or galleries). These collections are then made available, by themessaging server application 114, to the messaging client application104. Other processor- and memory-intensive processing of data may alsobe performed server-side by the messaging server application 114, inview of the hardware requirements for such processing.

The social network system 116 supports various social networkingfunctions and services, and makes these functions and services availableto the messaging server application 114. To this end, the social networksystem 116 maintains and accesses an entity graph within the database120. Examples of functions and services supported by the social networksystem 116 include the identification of other users of the messagingsystem 100 with whom a particular user has relationships or whom theuser is “following,” and also the identification of other entities andinterests of a particular user.

FIG. 2 is block diagram illustrating further details regarding themessaging system 100, according to exemplary embodiments. Specifically,the messaging system 100 is shown to comprise the messaging clientapplication 104 and the application server 112, which in turn embody anumber of subsystems, namely an ephemeral timer system 202, a collectionmanagement system 204, an annotation system 206, and an image processingsystem 208.

The ephemeral timer system 202 is responsible for enforcing thetemporary access to content permitted by the messaging clientapplication 104 and the messaging server application 114. To this end,the ephemeral timer system 202 incorporates a number of timers that,based on duration and display parameters associated with a message, orcollection of messages (e.g., a SNAPCHAT story), selectively display andenable access to messages and associated content via the messagingclient application 104. Further details regarding the operation of theephemeral timer system 202 are provided below.

The collection management system 204 is responsible for managingcollections of media (e.g., collections of text, image, video, and audiodata). In some examples, a collection of content (e.g., messages,including images, video, text, and audio) may be organized into an“event gallery” or an “event story.” Such a collection may be madeavailable for a specified time period, such as the duration of an eventto which the content relates. For example, content relating to a musicconcert may be made available as a “story” for the duration of thatmusic concert. The collection management system 204 may also beresponsible for publishing an icon that provides notification of theexistence of a particular collection to the user interface of themessaging client application 104.

The collection management system 204 furthermore includes a curationinterface 210 that allows a collection manager to manage and curate aparticular collection of content. For example, the curation interface210 enables an event organizer to curate a collection of contentrelating to a specific event (e.g., delete inappropriate content orredundant messages). Additionally, the collection management system 204employs machine vision (or image recognition technology) and contentrules to automatically curate a content collection. In certainembodiments, compensation may be paid to a user for inclusion ofuser-generated content in a collection. In such cases, the curationinterface 210 operates to automatically make payments to such users forthe use of their content.

The annotation system 206 provides various functions that enable a userto annotate or otherwise modify or edit media content associated with amessage. For example, the annotation system 206 provides functionsrelated to the generation and publishing of media overlays for messagesprocessed by the messaging system 100. For example, the annotationsystem 206 operatively supplies a media overlay (e.g., a SNAPCHATfilter) to the messaging client application 104 based on a geolocationof the client device 102. In another example, the annotation system 206operatively supplies a media overlay to the messaging client application104 based on other information, such as social network information ofthe user of the client device 102. A media overlay may include audio andvisual content and visual effects. Examples of audio and visual contentinclude pictures, texts, logos, animations, and sound effects. Anexample of a visual effect includes color overlaying. The audio andvisual content or the visual effects can be applied to a media contentitem (e.g., a photo) at the client device 102. For example, the mediaoverlay may include text that can be overlaid on top of a photographgenerated by the client device 102. In another example, the mediaoverlay includes an identification of a location (e.g., Venice Beach), aname of a live event, or a name of a merchant (e.g., Beach CoffeeHouse). In another example, the annotation system 206 uses thegeolocation of the client device 102 to identify a media overlay thatincludes the name of a merchant at the geolocation of the client device102. The media overlay may include other indicia associated with themerchant. The media overlays may be stored in the database 120 andaccessed through the database server 118.

In one exemplary embodiment, the annotation system 206 provides auser-based publication platform that enables users to select ageolocation on a map, and upload content associated with the selectedgeolocation. The user may also specify circumstances under which aparticular media overlay should be offered to other users. Theannotation system 206 generates a media overlay that includes theuploaded content and associates the uploaded content with the selectedgeolocation.

In another exemplary embodiment, the annotation system 206 provides amerchant-based publication platform that enables merchants to select aparticular media overlay associated with a geolocation via a biddingprocess. For example, the annotation system 206 associates the mediaoverlay of a highest-bidding merchant with a corresponding geolocationfor a predefined amount of time.

The image processing system 208 is dedicated to performing various imageprocessing operations, in some instances, with respect to images orvideo received within the payload of a message at the messaging serverapplication 114. As an example, the image processing system 208 providesfunctionality to allow a user to select an object or other element in anoriginal image to be removed and replaced using other portions of theimage. Further details regarding the image processing system 208 arediscussed below in reference to FIG. 4, according to some embodiments.

FIG. 3 is a schematic diagram 300 illustrating data which may be storedin the database 120 of the messaging server system 108, according tocertain exemplary embodiments. While the content of the database 120 isshown to comprise a number of tables, it will be appreciated that thedata could be stored in other types of data structures (e.g., as anobject-oriented database).

The database 120 includes message data stored within a message table314. An entity table 302 stores entity data, including an entity graph304. Entities for which records are maintained within the entity table302 may include individuals, corporate entities, organizations, objects,places, events, etc. Regardless of type, any entity regarding which themessaging server system 108 stores data may be a recognized entity. Eachentity is provided with a unique identifier, as well as an entity typeidentifier (not shown).

The entity graph 304 furthermore stores information regardingrelationships and associations between or among entities. Suchrelationships may be social, professional (e.g., work at a commoncorporation or organization), interested-based, or activity-based,merely for example.

The database 120 also stores annotation data, in the example form offilters, in an annotation table 312. Filters for which data is storedwithin the annotation table 312 are associated with and applied tovideos (for which data is stored in a video table 310) and/or images(for which data is stored in an image table 308). Filters, in oneexample, are overlays that are displayed as overlaid on an image orvideo during presentation to a recipient user. Filters may be of variestypes, including user-selected filters from a gallery of filterspresented to a sending user by the messaging client application 104 whenthe sending user is composing a message. Other types of filters includegeolocation filters (also known as geo-filters), which may be presentedto a sending user based on geographic location. For example, geolocationfilters specific to a neighborhood or special location may be presentedwithin a user interface by the messaging client application 104, basedon geolocation information determined by a Global Positioning System(GPS) unit of the client device 102. Another type of filter is a datafilter, which may be selectively presented to a sending user by themessaging client application 104, based on other inputs or informationgathered by the client device 102 during the message creation process.Examples of data filters include a current temperature at a specificlocation, a current speed at which a sending user is traveling, abattery life for a client device 102, or the current time.

Other annotation data that may be stored within the image table 308 isso-called “lens” data. A “lens” may be a real-time special effect andsound that may be added to an image or a video.

As mentioned above, the video table 310 stores video data which, in oneembodiment, is associated with messages for which records are maintainedwithin the message table 314. Similarly, the image table 308 storesimage data associated with messages for which message data is stored inthe entity table 302. The entity table 302 may associate variousannotations from the annotation table 312 with various images and videosstored in the image table 308 and the video table 310.

A story table 306 stores data regarding collections of messages andassociated image, video, or audio data, which are compiled into acollection (e.g., a SNAPCHAT story or a gallery). The creation of aparticular collection may be initiated by a particular user (e.g., auser for whom a record is maintained in the entity table 302). A usermay create a “personal story” in the form of a collection of contentthat has been created and sent/broadcast by that user. To this end, theuser interface of the messaging client application 104 may include anicon that is user-selectable to enable a sending user to add specificcontent to his or her personal story.

A collection may also constitute a “live story,” which is a collectionof content from multiple users that is created manually, automatically,or using a combination of manual and automatic techniques. For example,a “live story” may constitute a curated stream of user-submitted contentfrom various locations and events. Users whose client devices havelocation services enabled and who are at a common location or event at aparticular time may, for example, be presented with an option, via auser interface of the messaging client application 104, to contributecontent to a particular live story. The live story may be identified tothe user by the messaging client application 104, based on his or herlocation. The end result is a “live story” told from a communityperspective.

A further type of content collection is known as a “location story,”which enables a user whose client device 102 is located within aspecific geographic location (e.g., on a college or university campus)to contribute to a particular collection. In some embodiments, acontribution to a location story may require a second degree ofauthentication to verify that the end user belongs to a specificorganization or other entity (e.g., is a student on the universitycampus).

FIG. 4 is a block diagram illustrating functional components of theimage processing system 208 that forms part of the messaging system 100,according to some example embodiments. To avoid obscuring the inventivesubject matter with unnecessary detail, various functional components(e.g., modules, engines, and databases) that are not germane toconveying an understanding of the inventive subject matter have beenomitted from FIG. 4. However, a skilled artisan will readily recognizethat various additional functional components may be supported by theimage processing system 208 to facilitate additional functionality thatis not specifically described herein. As shown, the image processingsystem 208 includes a preprocessing component 402, a scaling component404, a recolorization component 406, and a post-processing component408.

The above referenced functional components of the image processingsystem 208 are configured to communicate with each other (e.g., via abus, shared memory, a switch, or APIs). Collectively, these componentsfacilitate interactive recolorization of a region of interest in animage in accordance with a user-specified color. In other words, thepreprocessing component 402, the scaling component 404, therecolorization component 406, and the post-processing component 408 workin conjunction to allow a user to select an object or other element inan original image to be recolorized, specify an alternative color forthe object or other element, and replace the color of the object orother element with the alternative color specified by the user.

The preprocessing component 402 is responsible for performing varioustransformations to images prior to recolorization to improve (e.g.,optimize) runtime speed of the recolorization process by, among otherthings, reducing the computational complexity of the recolorization.Additionally, the transformations applied to images by the preprocessingcomponent 402 enable a user to initiate a recolorization process on aregion of interest in an image with only a single stroke (e.g.,scribble) applied to the image. For purposes of this disclosure, a“stroke” may comprise a contoured mark such as a scribble applied overthe image through appropriate input by the user. Accordingly, a “single”stroke may comprise a single continuous (e.g., uninterrupted) contouredmark applied to the image through appropriate input by the user. Toenable a user to initiate the recolorization process using the singlestroke, the preprocessing component 402 is configured generate anexpanded mask by expanding the single stroke provided by the user, andusing the expanded stroke mask, the preprocessing component 402determines a precise boundary of the region of interest. In someinstances, the region of interest may include a target object forrecolorization (e.g., a specific object in the image that is to berecolored). The precise boundary of the region of interest is providedas input to the recolorization component 406, which performs therecolorization (e.g., recoloring) of the region of interest image.

In processing an image for recolorization, the preprocessing component402 may work in conjunction with the scaling component 404, which isconfigured to resize images (e.g., upsampling and downsampling). Forexample, prior to recolorization, the scaling component 404 may beutilized to downsample the region of interest in an image to reduce thecomputational complexity involved in recolorizing the region, therebyincreasing the speed with which the recolorization may be performed.Once the region of interest has been recolorized, the post-processingcomponent 408 may work in conjunction with the scaling component 404 toupsample the region of interest to return it to the resolution of theoriginal image. In resizing (e.g., scaling) images, the scalingcomponent 404 may use one of a number of different known scalingtechniques or algorithms (e.g., nearest-neighbor interpolation, bilinearalgorithms, and bicubic algorithms, Sinc resampling, Lanczos resampling,box sampling, Mipmap, Fourier transform, edge-directed interpolation,hqx, vectorization, or deep convolutional neural networks).

The recolorization component 406 is configured to recolorize (e.g., swapcolors) regions of interest in images. The boundary of the region ofinterest determined by the preprocessing component 402 is provided asinput to the recolorization component 406. The recolorization component406 utilizes a form of graphical model inference to recolorize theregion of interest while pixels in the image outside the region ofinterest are unchanged. Pixels inside the region of interest (but not onthe single stroke) are treated as unknowns, and the recolorizationcomponent 406 uses graphical model inference to solve for them in lightof the constraint that the colors of neighboring pixels with similarluminance must be similar as well. The result of this process is arecolorized image where an original color of the region of interest hasbeen replaced with an alternative color specified by the user.

The post-processing component 408 is responsible for processing an imageafter recolorization to improve the quality thereof. For example, thecombination of downsampling the region of interest prior torecolorization and upsampling the region of interest afterrecolorization may introduce blur into the recolorized image. To correctthe blur, the post-processing component 408 combines the luminancechannel of the original resolution region of interest with the U/V (orCb Cr) chromatic channels of the upsampled region of interest togenerate a clearer recolorization result.

As is understood by skilled artisans in the relevant computer andInternet-related arts, each functional component illustrated in FIG. 4may be implemented using hardware (e.g., a processor of a machine) or acombination of logic (e.g., executable software instructions) andhardware (e.g., memory and the processor of a machine) for executing thelogic. For example, any component included as part of the imageprocessing system 208 may physically include an arrangement of one ormore processors 410 (e.g., a subset of or among one or more processorsof a machine) configured to perform the operations described herein forthat component. As another example, any component of the imageprocessing system 208 may include software, hardware, or both, thatconfigure an arrangement of the one or more processors 410 to performthe operations described herein for that component. Accordingly,different components of the image processing system 208 may include andconfigure different arrangements of such processors 410 or a singlearrangement of such processors 410 at different points in time.

Furthermore, the various functional components depicted in FIG. 4 mayreside on a single machine (e.g., a client device or a server) or may bedistributed across several machines in various arrangements such ascloud-based architectures. Moreover, any two or more of these componentsmay be combined into a single component, and the functions describedherein for a single component may be subdivided among multiplecomponents. Functional details of these components are described belowwith respect to FIGS. 5-8.

FIGS. 5-8 are flow charts illustrating operations of the imageprocessing system 208 in performing an example method 500 for digitalimage editing, according to some embodiments. The method 500 may beembodied in computer-readable instructions for execution by one or moreprocessors such that the operations of the method 500 may be performedin part or in whole by the functional components of the image processingsystem 208; accordingly, the method 500 is described below by way ofexample with reference thereto. However, it shall be appreciated that atleast some of the operations of the method 500 may be deployed onvarious other hardware configurations and the method 500 is not intendedto be limited to the image processing system 208.

At operation 505, the image processing system 208 causes presentation ofan image on a display of the client device 102. The image processingsystem 208 may accesses the image from a memory of the client device 102or from the messaging server system 108. The image may be displayedwithin or as part of a user interface provided by the messaging clientapplication 104 for presentation on the client device 102, and in someinstances, the image may be captured by the client device 102. The userinterface may include one or more selectable icons that allow a user ofthe client device 102 to access various image editing functionality. Forexample, the user interface may include a selectable icon that allowsthe user to recolorize regions of the image (e.g., swap colors of theregions).

At operation 510, the image processing system 208 receives user inputthat includes a single stroke (e.g., a scribble) drawn on the image bythe user of the client device 102. The single stroke comprises a singlecontoured mark. In some instances, the stroke may be drawn over aparticular object depicted in the image, which is referred to as the“target object.” The user input may further include a color for thestroke specified by the user using elements of the user interface. Theuser may provide the user input by selecting the appropriate icon fromthe user interface, using an input element provided by the userinterface to specify the color, and tracing a scribble on the imagethrough appropriate interaction with an input device of the clientdevice 102 (e.g., using a finger to draw the scribble on a touch screenof the client device 102 without allowing the finger). For purposes ofclarity in describing the method 500, the image on which the userprovides the stroke may be referred to as the “original image.”

At operation 515, the preprocessing component 402 expands the singlestroke drawn on the image to generate an expanded stroke mask. Theexpanding of the single stroke may include user contour points of thesingle stroke as seed points in a breadth-first search, and propagatingthe stroke to other neighboring pixel points based on their Red, Green,Blue (RGB) color space value differences. In an example, the expandingof the single stroke may include applying a flood fill algorithm to theimage using the contour points of the stroke as seed points, where thetarget color for the flood fill algorithm is set based on a thresholdcolor difference to the user-specified color of the stroke, which is thereplacement color in the context of the flood fill algorithm. Furtherdetails of the operation 515 are discussed below in reference to FIG. 6.

At operation 520, the preprocessing component 402 refines the expandedstroke mask to determine a precise boundary (e.g., a more preciseboundary) of a region of interest in the image. The region of interestin the image is the region in the image that is to be recolorized (e.g.,replaced with the user-specified color) based on the user input, whichmay include the target object in instances in which the stroke is drawnover an object.

The refining of the expanded stroke mask may include computing a minimumenclosing rectangle (or other polygon) for the expanded stroke mask andapplying a Graph Cut algorithm to the image using the minimum enclosingrectangle as input. As will be discussed in further detail below inreference to FIG. 6, the application of the Graph Cut algorithm mayinclude applying a label to each pixel in the image based on whether thepixel is similar to foreground object or a background object where theminimum enclosing rectangle is used to define the foreground andbackground (e.g., objects within the rectangle are considered in theforeground and objects outside of the rectangle are considered in thebackground).

At operation 525, the recolorization component 406 recolorizes theregion of interest in the image. In recolorizing the region of interest,the recolorization component 406 replaces an original color of at leasta portion of the region of interest with an alternative color—theuser-specified color. For example, the recolorization component 406 mayreplace an original color of a target object with the user-specifiedcolor. The result of the recolorizing of the region of interest is arecolorized image.

In recolorizing the region of interest, the recolorization component 406may utilize one of many known image recolorizing techniques. Forexample, the recolorization component 406 may apply a form of graphicalmodel inference where pixels within the region of interest defined bythe precise boundary are treated as unknowns and the recolorizationcomponent 406 uses graphical model inference to solve for the unknownpixels with the constraint that neighboring pixels in space-time thathave similar intensities (e.g., luminance) are painted with the samecolor (e.g., the user-specified color). This constraint leads to aglobal optimization problem that can be solved efficiently usingstandard techniques (e.g., a quadratic cost function). In this manner,the recolorization component 406 performs color propagation in the colorchannels of the image while using the luminance channel as reference.

Consistent with some embodiments, the recolorization component 406 mayperform processing in the YUV color space where Y is the monochromaticluminance channel (also referred to simply as “intensity”), while U andV are the chrominance channels, encoding the color. The recolorizationcomponent 406 may utilize an algorithm that is given as input anintensity volume Y(x, y, t) and outputs two color volumes U(x, y, t) andV(x, y, t). To simplify notation, boldface letters (e.g., r, s) are usedin the following discussion to denote (x, y, t) triplets. Thus, Y(r) isthe intensity of a particular pixel.

As mentioned above, the recolorization component 406 performsrecolorization processing with the imposed constraint that twoneighboring pixels r, s should have similar colors if their intensitiesare similar. In this manner, the recolorization component 406 mayminimize the difference between the color U(r) at pixel r and theweighted average of the colors at neighboring pixels:

${J(U)} - {\sum\limits_{r}\left( {{U(r)} - {\sum\limits_{s \in {N{(r)}}}{w_{rs}{U(s)}}}} \right)^{2}}$

where w_(rs) is a weighting function that sums to one, large when Y(r)is similar to Y(s), and small when the two intensities are different.

In some embodiments, the following weighting function, which is based onthe squared difference between the two intensities, may be employed:

w_(rs)∝e^(−(Y(r)−Y(s))) ² ^(/2σ) ^(r) ²

In other embodiments, an alternative weighting function that is based onthe normalized correlation between the two intensities may be employed:

$w_{rs} \propto {1 + {\frac{1}{\sigma_{r}^{2}}\left( {{Y(r)} - \mu_{r}} \right)\left( {{Y(s)} - \mu_{r}} \right)}}$

where μ_(r) and σ_(r) are the mean and variance of the intensities in awindow around r.

The correlation affinity may be derived from assuming a local linearrelation between color and intensity. Formally, the recolorizationcomponent 406 assumes that the color at a pixel U(r) is a linearfunction of the intensity Y(r): U(r)=a_(i)Y(r)+b_(i) and the linearcoefficients a_(i);b_(i) are the same for all pixels in a smallneighborhood around r.

The notation r∈N(s) denotes the fact that r and s are neighboringpixels. In a single frame, two pixels are considered neighbors if theirimage locations are nearby. Given a set of locations r_(i) where one ormore colors are specified by the user u(r_(i))=u_(i), v(r_(i))=v_(i) therecolorization component 406 minimizes J(U), J(V) subject to theseconstraints. Since the cost functions are quadratic and the constraintsare linear, this optimization problem yields a large, sparse system oflinear equations, which may be solved using a number of standardmethods.

At operation 530, the image processing system 208 causes presentation ofthe recolorized image on the client device 102. The recolorized image isan edited version of the original image where the original color of atleast a portion of the region of interest has been replaced with analternative color—the user-specified color. For example, the recolorizedimage may include a target object whose original color has been swappedto the user-specified color.

As shown in FIG. 6, the method 500 may, in some embodiments, alsoinclude operations 605, 610, 615, 620, 625, and 630. The operations 605,610, and 615 may be performed as part of operation 515 (e.g., assub-operations or sub-routines), in which the preprocessing component402 expands the single stroke drawn on the image to generate an expandedstroke mask.

At operation 605, the preprocessing component 402 identifies one or morecontour points on the single stroke. A contour point is a location onthe stroke. More specifically, the identified contour points maycorrespond to inflection points along the stroke at which the curvatureof the stroke changes direction.

For each pixel of the image corresponding to one of the identifiedcontour points, the preprocessing component 402 identifies, at operation610, neighboring pixels that have a color (e.g., defined in the RGBcolor space) within a threshold color difference to the pixel. Forexample, for a given pixel, the preprocessing component 402 may identifyneighboring pixels that are within a 5% color difference to the pixel.For a given contour point, the preprocessing component 402 may identifythe neighboring pixels within the threshold color difference byperforming a breadth-first search using the pixel corresponding to thecontour point as the seed.

At operation 615, the preprocessing component 402 replaces the color ofthe identified pixels with an alternative color. More specifically, thepreprocessing component 402 replaces the color of the identified pixelswith the user-specified color of the stroke. The result of operation 615is the expanded stroke mask that comprises a sparse set of points thatinclude points along the original stroke as well as the neighboringpixels identified at operation 610. Those of ordinary skill in the artmay recognize that the operations 610 and 615 may be performed as partof a flood fill algorithm, in which the pixels corresponding to contourpoints are used as the starting nodes, the target color includes colorswithin the threshold color difference of the user-specified color, andthe replacement color is the user-specified color.

Operations 620, 625, and 630 may be performed as part of the operation520, in which the preprocessing component 402 refines the expandedstroke mask to determine the precise boundary of the region of interestin the image. At operation 620, the preprocessing component 402 computesa convex hull of the expanded stroke mask. The convex hull representsthe smallest convex set that contains the sparse set of points that formthe expanded stroke mask. For example, in some instances, the convexhull corresponds to the minimum enclosing rectangle for the sparse setof points that form the expanded stroke mask. The preprocessingcomponent 402 may utilize one of a number of known techniques oralgorithms to compute the convex hull of a set of points. In general,the preprocessing component 402 may utilize the following function tocompute the convex hull of the expanded stroke mask:

${{Conv}(S)} = \left\{ {{{\sum\limits_{i = 1}^{S}\;{\alpha_{i}x_{i}}}❘{\left( {\forall\;{i:{\alpha_{i} \geq 0}}} \right)\bigwedge{\sum\limits_{i = 1}^{S}\alpha_{i}}}} = 1} \right\}$

Where S represents the sparse set of points that form the expandedstroke mask. In the function presented above, each point x_(i) in S isassigned a weight or coefficient α_(i) in such a way that thecoefficients are all non-negative and sum to one, and these weights areused to compute a weighted average of the points. For each choice ofcoefficients, the resulting convex combination is a point in the convexhull, and the whole convex hull can be computed by selectingcoefficients in all possible ways.

At operation 620, the preprocessing component 402 generates an enlargedconvex hull mask by enlarging the convex hull by a predetermined amount.For example, the preprocessing component 402 may dilate the convex hullby 20%, thereby enlarging a size (e.g., area) of the convex hull.

At operation 625, the preprocessing component 402 segments the imagebased on the enlarged convex hull mask. In doing so, the preprocessingcomponent 402 assigns a label to each pixel in the image based in theenlarged convex hull mask. More specifically, the preprocessingcomponent 402 assigns a label to each pixel in the image based onwhether the pixel is similar to foreground object (e.g., the targetobject) or a background object. In this case, the enlarged convex hullmask is used to define the foreground and background. In particular,objects within the rectangle are considered in the foreground andobjects outside of the rectangle are considered in the background. Thelabels applied to the pixels indicate whether the pixel is similar to aforeground object or a background object. The result of the applicationof the labels to the pixels is a precise boundary that defines a regionof interest. In this case, pixels with labels corresponding tosimilarity to a foreground image establish the boundary of the region ofinterest.

One of ordinary skill in the art may recognize that operation 625 maycorrespond to or be accomplished by utilizing a Graph Cut algorithm,which is an image segmentation method based on graph cuts. A boundingbox, in this case the enlarged convex hull mask, is provided as input tothe Graph Cut algorithm, and the algorithm estimates the colordistribution of a target object within the bounding box and that of thebackground using a Gaussian mixture model. The color distributionestimates are used to construct a Markov random field over the pixellabels, with an energy function that prefers connected regions havingthe same label, and running a graph-cut-based optimization to infertheir values. This procedure may be repeated until convergence isachieved.

As shown in FIG. 7, the method 500 may also include operation 705, whichmay be performed subsequent to operation 520, in which the preprocessingcomponent 402 refines the expanded stroke mask to determine the preciseboundary of the region of interest in the image. At operation 705, thepreprocessing component 402 simulates one or more additional strokes.The simulating of the one or more additional strokes on the imagecomprises performing bilateral filtering on the image to remove highfrequency edges; performing edge detection on the image to generate anedge map; and dilating the edge map such that the edges are thickened.

As shown in FIG. 8, the method 500 may, in some embodiments, includeoperations 805, 810, and 815. Operation 805 may be performed prior tooperation 525, in which the recolorization component 406 recolorizes theregion of interest in the image. At operation 805, the sampling rateconversion component 404 downsamples the region of interest.Downsampling the region of interest prior to recolorizing results in animprovement to the speed with which the region of interest isrecolorized because the downsampling reduces the computationalcomplexity involved in recolorizing the region of interest.

Operations 810 and 815 may be performed subsequent to operation 525, inwhich the recolorization component 406 recolorizes the region ofinterest in the image. At operation 810, the sampling rate conversioncomponent 404 upsamples the recolorized region of interest. The samplingrate conversion component 404 upsamples the recolorized region ofinterest to return it to the resolution of the original image.

In some instances, the downsampling of the region of interest prior torecolorizing and upsampling after the recolorizing causes therecolorized image to be blurred compared to the original image. Toaddress the blurriness of the recolorized image after upsampling, thepost-processing component 408, at operation 815, combines color channelsof the recolorized image with the luminance channel of the originalimage. In doing so, the post-processing component 408 may convert theRGB color space definition of both the original and recolorized imagesto the YCbCr color space using a mathematical coordinate transformation.In the YCbCr color space, the luminance channel corresponds to the “Y”channel, and the “Cb” and “Cr” chrominance channels correspond to thecolor channels. Thus, in combining the color channels of the recolorizedimage with the luminance channel of the original image, thepost-processing component 408 merges the “Y” channel of the originalimage with the “Cb” and “Cr” channels of the recolorized image into athree-dimensional array, which forms a new, clearer (e.g., unblurred)version of the recolorized image.

FIGS. 9A, 9B, 9C, and 9D are interface diagrams illustrating aspects ofuser interfaces provided by the messaging system 100, according to someembodiments. In particular, FIG. 9A illustrates an original image 900that may be captured by and presented within a user interface display onthe client device 102. The user interface includes a set of icons 902,each of which corresponds to a particular image editing functionalityprovided to a user of the client device 102. For example, selection oficon 904 allows a user to recolorize regions of the image 900.

FIG. 9B illustrates a graphical input element 906 of the user interfacefrom which a user may specify a color to use in recolorizing regions(e.g., objects) within the image 900. In this example, the user hasspecified color 908. The graphical input element 906 may be provided inresponse to user selection of the icon 904.

FIG. 9C illustrates a single stroke 910 drawn on the image 900 by theuser. The user may create the stroke 910, for example, by moving his orher finger over the image 900 on the touch screen of the client device102. The stroke 910 is drawn over a target object 912, which in thiscase corresponds to liquid in a cup. Further, as shown, the color of thestroke 910 is the user-specified color 908.

FIG. 9D illustrates a modified image 950 that may be presented withinthe user interface display on the client device 102. The modified image950 is an edited version of the original image 900 generated by applyingthe techniques described herein to the target object 912 thatcorresponds to the stroke 910. More specifically, in the modified image950, the original color of the target object 912 (the liquid) has beenrecolorized in accordance with the user-specified color 908. In otherwords, the original color of the target object 912 corresponding to thestroke 910 has been replaced with the user-specified color 908.

Software Architecture

FIG. 10 is a block diagram illustrating an example software architecture1006, which may be used in conjunction with various hardwarearchitectures herein described. FIG. 10 is a non-limiting example of asoftware architecture and it will be appreciated that many otherarchitectures may be implemented to facilitate the functionalitydescribed herein. The software architecture 1006 may execute on hardwaresuch as a machine 1100 of FIG. 11 that includes, among other things,processors 1104, memory/storage 1106, and I/O components 1118. Arepresentative hardware layer 1052 is illustrated and can represent, forexample, the machine 1100 of FIG. 11. The representative hardware layer1052 includes a processing unit 1054 having associated executableinstructions 1004. The executable instructions 1004 represent theexecutable instructions of the software architecture 1006, includingimplementation of the methods, components, and so forth describedherein. The hardware layer 1052 also includes memory and/or storage1056, which also have the executable instructions 1004. The hardwarelayer 1052 may also comprise other hardware 1058.

As used herein, the term “component” may refer to a device, a physicalentity, or logic having boundaries defined by function or subroutinecalls, branch points, APIs, and/or other technologies that provide forthe partitioning or modularization of particular processing or controlfunctions. Components may be combined via their interfaces with othercomponents to carry out a machine process. A component may be a packagedfunctional hardware unit designed for use with other components and apart of a program that usually performs a particular function of relatedfunctions.

Components may constitute either software components (e.g., codeembodied on a machine-readable medium) or hardware components. A“hardware component” is a tangible unit capable of performing certainoperations and may be configured or arranged in a certain physicalmanner. In various exemplary embodiments, one or more computer systems(e.g., a standalone computer system, a client computer system, or aserver computer system) or one or more hardware components of a computersystem (e.g., a processor or a group of processors) may be configured bysoftware (e.g., an application or application portion) as a hardwarecomponent that operates to perform certain operations as describedherein. A hardware component may also be implemented mechanically,electronically, or any suitable combination thereof. For example, ahardware component may include dedicated circuitry or logic that ispermanently configured to perform certain operations.

A hardware component may be a special-purpose processor, such as aField-Programmable Gate Array (FPGA) or an Application-SpecificIntegrated Circuit (ASIC). A hardware component may also includeprogrammable logic or circuitry that is temporarily configured bysoftware to perform certain operations. For example, a hardwarecomponent may include software executed by a general-purpose processoror other programmable processor. Once configured by such software,hardware components become specific machines (or specific components ofa machine) uniquely tailored to perform the configured functions and areno longer general-purpose processors. It will be appreciated that thedecision to implement a hardware component mechanically, in dedicatedand permanently configured circuitry, or in temporarily configuredcircuitry (e.g., configured by software) may be driven by cost and timeconsiderations.

A processor may be, or include, any circuit or virtual circuit (aphysical circuit emulated by logic executing on an actual processor)that manipulates data values according to control signals (e.g.,“commands,” “op codes,” “machine code,” etc.) and that producescorresponding output signals that are applied to operate a machine. Aprocessor may, for example, be a Central Processing Unit (CPU), aReduced Instruction Set Computing (RISC) processor, a ComplexInstruction Set Computing (CISC) processor, a Graphics Processing Unit(GPU), a Digital Signal Processor (DSP), an ASIC, a Radio-FrequencyIntegrated Circuit (RFIC), or any combination thereof. A processor mayfurther be a multi-core processor having two or more independentprocessors (sometimes referred to as “cores”) that may executeinstructions contemporaneously.

Accordingly, the phrase “hardware component” (or “hardware-implementedcomponent”) should be understood to encompass a tangible entity, be thatan entity that is physically constructed, permanently configured (e.g.,hardwired), or temporarily configured (e.g., programmed) to operate in acertain manner or to perform certain operations described herein.Considering embodiments in which hardware components are temporarilyconfigured (e.g., programmed), each of the hardware components need notbe configured or instantiated at any one instance in time. For example,where a hardware component comprises a general-purpose processorconfigured by software to become a special-purpose processor, thegeneral-purpose processor may be configured as respectively differentspecial-purpose processors (e.g., comprising different hardwarecomponents) at different times. Software accordingly configures aparticular processor or processors, for example, to constitute aparticular hardware component at one instance of time and to constitutea different hardware component at a different instance of time. Hardwarecomponents can provide information to, and receive information from,other hardware components. Accordingly, the described hardwarecomponents may be regarded as being communicatively coupled. Wheremultiple hardware components exist contemporaneously, communications maybe achieved through signal transmission (e.g., over appropriate circuitsand buses) between or among two or more of the hardware components. Inembodiments in which multiple hardware components are configured orinstantiated at different times, communications between or among suchhardware components may be achieved, for example, through the storageand retrieval of information in memory structures to which the multiplehardware components have access.

For example, one hardware component may perform an operation and storethe output of that operation in a memory device to which it iscommunicatively coupled. A further hardware component may then, at alater time, access the memory device to retrieve and process the storedoutput. Hardware components may also initiate communications with inputor output devices, and can operate on a resource (e.g., a collection ofinformation). The various operations of example methods described hereinmay be performed, at least partially, by one or more processors that aretemporarily configured (e.g., by software) or permanently configured toperform the relevant operations. Whether temporarily or permanentlyconfigured, such processors may constitute processor-implementedcomponents that operate to perform one or more operations or functionsdescribed herein. As used herein, “processor-implemented component”refers to a hardware component implemented using one or more processors.Similarly, the methods described herein may be at least partiallyprocessor-implemented, with a particular processor or processors beingan example of hardware. For example, at least some of the operations ofa method may be performed by one or more processors orprocessor-implemented components.

Moreover, the one or more processors may also operate to supportperformance of the relevant operations in a “cloud computing”environment or as a “software as a service” (SaaS). For example, atleast some of the operations may be performed by a group of computers(as examples of machines including processors), with these operationsbeing accessible via a network (e.g., the Internet) and via one or moreappropriate interfaces (e.g., an API). The performance of certain of theoperations may be distributed among the processors, not only residingwithin a single machine, but deployed across a number of machines. Insome exemplary embodiments, the processors or processor-implementedcomponents may be located in a single geographic location (e.g., withina home environment, an office environment, or a server farm). In otherexemplary embodiments, the processors or processor-implementedcomponents may be distributed across a number of geographic locations.

In the exemplary architecture of FIG. 10, the software architecture 1006may be conceptualized as a stack of layers where each layer providesparticular functionality. For example, the software architecture 1006may include layers such as an operating system 1002, libraries 1020,frameworks/middleware 1018, applications 1016, and a presentation layer1014. Operationally, the applications 1016 and/or other componentswithin the layers may invoke API calls 1008 through the software stackand receive a response as messages 1010. The layers illustrated arerepresentative in nature and not all software architectures have alllayers. For example, some mobile or special-purpose operating systemsmay not provide a frameworks/middleware 1018 layer, while others mayprovide such a layer. Other software architectures may includeadditional or different layers.

The operating system 1002 may manage hardware resources and providecommon services. The operating system 1002 may include, for example, akernel 1022, services 1024, and drivers 1026. The kernel 1022 may act asan abstraction layer between the hardware and the other software layers.For example, the kernel 1022 may be responsible for memory management,processor management (e.g., scheduling), component management,networking, security settings, and so on. The services 1024 may provideother common services for the other software layers. The drivers 1026are responsible for controlling or interfacing with the underlyinghardware. For instance, the drivers 1026 include display drivers, cameradrivers, Bluetooth® drivers, flash memory drivers, serial communicationdrivers (e.g., Universal Serial Bus (USB) drivers), Wi-Fi® drivers,audio drivers, power management drivers, and so forth depending on thehardware configuration.

The libraries 1020 provide a common infrastructure that is used by theapplications 1016 and/or other components and/or layers. The libraries1020 provide functionality that allows other software components toperform tasks in an easier fashion than by interfacing directly with theunderlying operating system 1002 functionality (e.g., kernel 1022,services 1024, and/or drivers 1026). The libraries 1020 may includesystem libraries 1044 (e.g., C standard library) that may providefunctions such as memory allocation functions, string manipulationfunctions, mathematical functions, and the like. In addition, thelibraries 1020 may include API libraries 1046 such as media libraries(e.g., libraries to support presentation and manipulation of variousmedia formats such as MPEG4, H.264, MP3, AAC, AMR, JPG, and PNG),graphics libraries (e.g., an OpenGL framework that may be used to render2D and 3D graphic content on a display), database libraries (e.g.,SQLite that may provide various relational database functions), weblibraries (e.g., WebKit that may provide web browsing functionality),and the like. The libraries 1020 may also include a wide variety ofother libraries 1048 to provide many other APIs to the applications 1016and other software components/modules.

The frameworks/middleware 1018 provide a higher-level commoninfrastructure that may be used by the applications 1016 and/or othersoftware components/modules. For example, the frameworks/middleware 1018may provide various graphic user interface (GUI) functions, high-levelresource management, high-level location services, and so forth. Theframeworks/middleware 1018 may provide a broad spectrum of other APIsthat may be utilized by the applications 1016 and/or other softwarecomponents/modules, some of which may be specific to a particularoperating system 1002 or platform.

The applications 1016 include built-in applications 1038 and/orthird-party applications 1040. Examples of representative built-inapplications 1038 may include, but are not limited to, a contactsapplication, a browser application, a book reader application, alocation application, a media application, a messaging application,and/or a game application. The third-party applications 1040 may includean application developed using the ANDROID™ or IOS™ software developmentkit (SDK) by an entity other than the vendor of the particular platform,and may be mobile software running on a mobile operating system such asIOS™, ANDROID™, WINDOWS® Phone, or other mobile operating systems. Thethird-party applications 1040 may invoke the API calls 1008 provided bythe mobile operating system (such as the operating system 1002) tofacilitate functionality described herein.

The applications 1016 may use built-in operating system functions (e.g.,kernel 1022, services 1024, and/or drivers 1026), libraries 1020, andframeworks/middleware 1018 to create user interfaces to interact withusers of the system. Alternatively, or additionally, in some systemsinteractions with a user may occur through a presentation layer, such asthe presentation layer 1014. In these systems, the application/component“logic” can be separated from the aspects of the application/componentthat interact with a user.

Exemplary Machine

FIG. 11 is a block diagram illustrating components (also referred toherein as “modules”) of a machine 1100, according to some exemplaryembodiments, able to read instructions from a machine-readable medium(e.g., a machine-readable storage medium) and perform any one or more ofthe methodologies discussed herein. Specifically, FIG. 11 shows adiagrammatic representation of the machine 1100 in the example form of acomputer system, within which instructions 1110 (e.g., software, aprogram, an application, an applet, an app, or other executable code)for causing the machine 1100 to perform any one or more of themethodologies discussed herein may be executed. As such, theinstructions 1110 may be used to implement modules or componentsdescribed herein. The instructions 1110 transform the general,non-programmed machine 1100 into a particular machine 1100 programmed tocarry out the described and illustrated functions in the mannerdescribed. In alternative embodiments, the machine 1100 operates as astandalone device or may be coupled (e.g., networked) to other machines.In a networked deployment, the machine 1100 may operate in the capacityof a server machine or a client machine in a server-client networkenvironment, or as a peer machine in a peer-to-peer (or distributed)network environment. The machine 1100 may comprise, but not be limitedto, a server computer, a client computer, a personal computer (PC), atablet computer, a laptop computer, a netbook, a set-top box (STB), apersonal digital assistant (PDA), an entertainment media system, acellular telephone, a smart phone, a mobile device, a wearable device(e.g., a smart watch), a smart home device (e.g., a smart appliance),other smart devices, a web appliance, a network router, a networkswitch, a network bridge, or any machine capable of executing theinstructions 1110, sequentially or otherwise, that specify actions to betaken by machine 1100. Further, while only a single machine 1100 isillustrated, the term “machine” shall also be taken to include acollection of machines that individually or jointly execute theinstructions 1110 to perform any one or more of the methodologiesdiscussed herein.

The machine 1100 may include processors 1104, memory/storage 1106, andI/O components 1118, which may be configured to communicate with eachother such as via a bus 1102. The memory/storage 1106 may include amemory 1114, such as a main memory, or other memory storage, and astorage unit 1116, both accessible to the processors 1104 such as viathe bus 1102. The storage unit 1116 and memory 1114 store theinstructions 1110 embodying any one or more of the methodologies orfunctions described herein. The instructions 1110 may also reside,completely or partially, within the memory 1114, within the storage unit1116, within at least one of the processors 1104 (e.g., within theprocessor's cache memory), or any suitable combination thereof, duringexecution thereof by the machine 1100. Accordingly, the memory 1114, thestorage unit 1116, and the memory of the processors 1104 are examples ofmachine-readable media.

As used herein, the term “machine-readable medium,” “computer-readablemedium,” or the like may refer to any component, device, or othertangible medium able to store instructions and data temporarily orpermanently. Examples of such media may include, but are not limited to,random-access memory (RAM), read-only memory (ROM), buffer memory, flashmemory, optical media, magnetic media, cache memory, other types ofstorage (e.g., Electrically Erasable Programmable Read-Only Memory(EEPROM)), and/or any suitable combination thereof. The term“machine-readable medium” should be taken to include a single medium ormultiple media (e.g., a centralized or distributed database, orassociated caches and servers) able to store instructions. The term“machine-readable medium” may also be taken to include any medium, orcombination of multiple media, that is capable of storing instructions(e.g., code) for execution by a machine, such that the instructions,when executed by one or more processors of the machine, cause themachine to perform any one or more of the methodologies describedherein. Accordingly, a “machine-readable medium” may refer to a singlestorage apparatus or device, as well as “cloud-based” storage systems orstorage networks that include multiple storage apparatus or devices. Theterm “machine-readable medium” excludes signals per se.

The I/O components 1118 may include a wide variety of components toprovide a user interface for receiving input, providing output,producing output, transmitting information, exchanging information,capturing measurements, and so on. The specific I/O components 1118 thatare included in the user interface of a particular machine 1100 willdepend on the type of machine. For example, portable machines such asmobile phones will likely include a touch input device or other suchinput mechanisms, while a headless server machine will likely notinclude such a touch input device. It will be appreciated that the I/Ocomponents 1118 may include many other components that are not shown inFIG. 11. The I/O components 1118 are grouped according to functionalitymerely for simplifying the following discussion and the grouping is inno way limiting. In various exemplary embodiments, the I/O components1118 may include output components 1126 and input components 1128. Theoutput components 1126 may include visual components (e.g., a displaysuch as a plasma display panel (PDP), a light emitting diode (LED)display, a liquid crystal display (LCD), a projector, or a cathode raytube (CRT)), acoustic components (e.g., speakers), haptic components(e.g., a vibratory motor, resistance mechanisms), other signalgenerators, and so forth. The input components 1128 may includealphanumeric input components (e.g., a keyboard, a touch screenconfigured to receive alphanumeric input, a photo-optical keyboard, orother alphanumeric input components), point-based input components(e.g., a mouse, a touchpad, a trackball, a joystick, a motion sensor, orother pointing instruments), tactile input components (e.g., a physicalbutton, a touch screen that provides location and/or force of touches ortouch gestures, or other tactile input components), audio inputcomponents (e.g., a microphone), and the like. The input components 1128may also include one or more image-capturing devices, such as a digitalcamera for generating digital images and/or video.

In further exemplary embodiments, the I/O components 1118 may includebiometric components 1130, motion components 1134, environmentcomponents 1136, or position components 1138, as well as a wide array ofother components. For example, the biometric components 1130 may includecomponents to detect expressions (e.g., hand expressions, facialexpressions, vocal expressions, body gestures, or eye tracking), measurebiosignals (e.g., blood pressure, heart rate, body temperature,perspiration, or brain waves), identify a person (e.g., voiceidentification, retinal identification, facial identification,fingerprint identification, or electroencephalogram-basedidentification), and the like. The motion components 1134 may includeacceleration sensor components (e.g., accelerometer), gravitation sensorcomponents, rotation sensor components (e.g., gyroscope), and so forth.The environment components 1136 may include, for example, illuminationsensor components (e.g., photometer), temperature sensor components(e.g., one or more thermometers that detect ambient temperature),humidity sensor components, pressure sensor components (e.g.,barometer), acoustic sensor components (e.g., one or more microphonesthat detect background noise), proximity sensor components (e.g.,infrared sensors that detect nearby objects), gas sensors (e.g., gasdetection sensors to detect concentrations of hazardous gases for safetyor to measure pollutants in the atmosphere), or other components thatmay provide indications, measurements, or signals corresponding to asurrounding physical environment. The position components 1138 mayinclude location sensor components (e.g., a GPS receiver component),altitude sensor components (e.g., altimeters or barometers that detectair pressure from which altitude may be derived), orientation sensorcomponents (e.g., magnetometers), and the like.

Communication may be implemented using a wide variety of technologies.The I/O components 1118 may include communication components 1140operable to couple the machine 1100 to a network 1132 or devices 1120via a coupling 1124 and a coupling 1122 respectively. For example, thecommunication components 1140 may include a network interface componentor other suitable device to interface with the network 1132. In furtherexamples, the communication components 1140 may include wiredcommunication components, wireless communication components, cellularcommunication components, Near Field Communication (NFC) components,Bluetooth® components (e.g., Bluetooth® Low Energy), Wi-Fi® components,and other communication components to provide communication via othermodalities. The devices 1120 may be another machine or any of a widevariety of peripheral devices (e.g., a peripheral device coupled via aUSB).

Moreover, the communication components 1140 may detect identifiers orinclude components operable to detect identifiers. For example, thecommunication components 1140 may include Radio Frequency Identification(RFID) tag reader components, NFC smart tag detection components,optical reader components (e.g., an optical sensor to detectone-dimensional bar codes such as Universal Product Code (UPC) bar code,multi-dimensional bar codes such as Quick Response (QR) code, Azteccode, Data Matrix, Dataglyph, MaxiCode, PDF4111, Ultra Code, UCC RSS-2Dbar code, and other optical codes), or acoustic detection components(e.g., microphones to identify tagged audio signals). In addition, avariety of information may be derived via the communication components1140, such as location via Internet Protocol (IP) geo-location, locationvia Wi-Fi® signal triangulation, location via detecting an NFC beaconsignal that may indicate a particular location, and so forth.

Where a phrase similar to “at least one of A, B, or C,” “at least one ofA, B, and C,” “one or more of A, B, or C,” or “one or more of A, B, andC” is used, it is intended that the phrase be interpreted to mean that Aalone may be present in an embodiment, B alone may be present in anembodiment, C alone may be present in an embodiment, or any combinationof the elements A, B, and C may be present in a single embodiment; forexample, A and B, A and C, B and C, or A and B and C may be present.

Changes and modifications may be made to the disclosed embodimentswithout departing from the scope of the present disclosure. These andother changes or modifications are intended to be included within thescope of the present disclosure, as expressed in the following claims.

A portion of the disclosure of this patent document contains materialthat is subject to copyright protection. The copyright owner has noobjection to the facsimile reproduction by anyone of the patent documentor the patent disclosure, as it appears in the Patent and TrademarkOffice patent files or records, but otherwise reserves all copyrightrights whatsoever. The following notice applies to the software and dataas described below and in the drawings that form a part of thisdocument: Copyright 2017, SNAPCHAT, INC., All Rights Reserved.

1. A method comprising: on a client device, causing presentation of auser interface comprising an image and an input element comprisingmultiple selectable colors; detecting a selected color from the multipleselectable colors; detecting a user input in the form of a singleuninterrupted stroke drawn on the image; in response to the singleuninterrupted stroke: based on the single uninterrupted strokedetermining a region of interest in the image and filling the region ofinterest with the selected color to produce a recolorized image; andcausing presentation of the recolorized image on the client device. 2.The method of claim 1, comprising expanding the single uninterruptedstroke to generate an expanded stroke mask.
 3. The method of claim 2,comprising refining the expanded stroke mask to determine a preciseboundary of the region of interest.
 4. The method of claim 3, whereinthe refining of the expanded stroke mask comprises: computing a convexhull of the expanded stroke mask; dilating the convex hull by apredetermined amount to generate an enlarged convex hull mask; andsegmenting the image based on the enlarged convex hull mask.
 5. Themethod of claim 3, wherein the refining of the expanded stroke maskfurther comprises simulating one or more additional strokes on theimage.
 6. The method of claim 5, wherein the simulating of the one ormore additional strokes on the image comprises: performing bilateralfiltering on the image to remove high-frequency edges; performing edgedetection on the image to generate an edge map; and dilating the edgemap such that the edges are thickened.
 7. The method of claim 1, whereinthe operations further comprise generating an expanded stroke mask byperforming operations comprising: identifying one or more contour pointson the single uninterrupted stroke; and applying a flood fill algorithmto the image using the one or more contour points as seeds, the applyingof the flood fill algorithm resulting in the expanded stroke mask. 8.The method of claim 1, comprising generating an expanded stroke mask byperforming operations comprising: identifying one or more contour pointson the single uninterrupted stroke; identifying connected pixels havinga color within a threshold color difference to the pixel; and replacingthe color of connected pixels with the user-specified color, thereplacing of the color of the connected pixels resulting in the expandedstroke mask.
 9. The method of claim 1, comprising: prior to recolorizingthe region of interest of the image, downsampling the region ofinterest; and subsequent to recolorizing the region of interest,upsampling the recolorized region of interest.
 10. The method of claim9, comprising combining color channels of the upsampled region ofinterest with an original luminance channel of the region of interest.11. A system comprising: one or more processors; and a non-transitorycomputer readable storage medium comprising instructions that whenexecuted by the one or more processors cause the one or more processorsto perform operations comprising: on a client device, causingpresentation of a user interface comprising an image and an inputelement comprising multiple selectable colors; detecting a selectedcolor from the multiple selectable colors; detecting a user input in theform of a single uninterrupted stroke drawn on the image; in response tothe single uninterrupted stroke: based on the single uninterruptedstroke determining a region of interest in the image and filling theregion of interest with the selected color to produce a recolorizedimage; and causing presentation of the recolorized image on the clientdevice.
 12. The system of claim 11, wherein the operations caused byinstructions executed by the one or processors further include:expanding the single uninterrupted stroke to generate an expanded strokemask.
 13. The method of claim 12, wherein the operations caused byinstructions executed by the one or processors further include: refiningthe expanded stroke mask to determine a precise boundary of the regionof interest.
 14. The method of claim 13, wherein the refining of theexpanded stroke mask comprises: computing a convex hull of the expandedstroke mask; dilating the convex hull by a predetermined amount togenerate an enlarged convex hull mask; and segmenting the image based onthe enlarged convex hull mask.
 15. The method of claim 13, wherein therefining of the expanded stroke mask further comprises simulating one ormore additional strokes on the image.
 16. The method of claim 15,wherein the simulating of the one or more additional strokes on theimage comprises: performing bilateral filtering on the image to removehigh-frequency edges; performing edge detection on the image to generatean edge map; and dilating the edge map such that the edges arethickened.
 17. The system of claim 11, wherein the operations furtherinclude generating an expanded stroke mask by performing operationscomprising: identifying one or more contour points on the singleuninterrupted stroke; and applying a flood fill algorithm to the imageusing the one or more contour points as seeds, the applying of the floodfill algorithm resulting in the expanded stroke mask.
 18. The system ofclaim 11, wherein the operations caused by instructions executed by theone or processors further include: generating an expanded stroke mask byperforming operations comprising: identifying one or more contour pointson the single uninterrupted stroke; identifying connected pixels havinga color within a threshold color difference to the pixel; and replacingthe color of connected pixels with the user-specified color, thereplacing of the color of the connected pixels resulting in the expandedstroke mask.
 19. The system of claim 11, wherein the operations causedby instructions executed by the one or processors further include: priorto recolorizing the region of interest of the image, downsampling theregion of interest; and subsequent to recolorizing the region ofinterest, upsampling the recolorized region of interest.
 20. Amachine-readable non-transitory storage medium having instruction dataexecutable by a machine to cause the machine to perform operationscomprising: on a client device, causing presentation of a user interfacecomprising an image and an input element comprising multiple selectablecolors; detecting a selected color from the multiple selectable colors;detecting a user input in the form of a single uninterrupted strokedrawn on the image; in response to the single uninterrupted stroke:based on the single uninterrupted stroke determining a region ofinterest in the image and filling the region of interest with theselected color to produce a recolorized image; and causing presentationof the recolorized image on the client device.